﻿using rmTest.Common.ConstUtil;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace rmTest.Common
{
    public class ConsoleUtil
    {

        public static void Output(StringBuilder builder)
        {
            //输出
            foreach (var item in builder.ToString())
            {
                Console.Write(item);
                System.Threading.Thread.Sleep(50);
            }
            Console.WriteLine();
        }

        public static void Output(string log, ConsoleColor color = ConsoleColor.White, bool isSlow = false)
        {
            lock (ConstArgs.ObjectLock)
            {
                //输出
                foreach (var item in log)
                {
                    Console.ForegroundColor = color;
                    Console.Write(item);
                    if (isSlow)
                    {
                        int s = RandomUtil.GetRandomNumber(10, 30);
                        System.Threading.Thread.Sleep(s);
                    }
                }
                Console.WriteLine();
            }
        }
    }
}
